package com.googlecode.lightest.core

import java.util.List;

import groovy.util.GroovyTestCase
import com.googlecode.lightest.core.tutorial.TutorialNoEnv

/**
 * Unit tests for SimpleDispatcherAssignmentStrategy.
 */
class SimpleDispatcherAssignmentStrategyTest extends GroovyTestCase {
    /**
     * Test that if assigning a test that doesn't support any of the
     * configured environments, the assign method fails in a timely manner.
     * 
     * The failure logic isn't currently active, so this test isn't applicable.
     */
    /*
    void testFailAssignIfNoSupportedEnvironments() {
        def contextClassLoader = Thread.currentThread().contextClassLoader
        def classLoader = new GroovyClassLoader(contextClassLoader)
        def contextClass = LightestContextFactory.DEFAULT_CONTEXT_CLASS
        def ctxFactory = new LightestContextFactory(contextClass, classLoader, null)
        
        LightestTestCase testcase = new TutorialNoEnv()
        SimpleDispatcherAssignmentStrategy strat = new SimpleDispatcherAssignmentStrategy()
        ThreadedLightestContext ctx = new ThreadedLightestContext(ctxFactory)
        strat.setDispatchers([new TaskDispatcher(ctx)])
        
        long start = System.currentTimeMillis()
        try {
            strat.assign(testcase)
            fail('Excepted exception was not thrown')
        } catch(IllegalArgumentException ex) {
            long diff = System.currentTimeMillis() - start
            assertTrue('Assignment should have failed more rapidly', diff < 5000)
        }
    }
    */
}